package mspbots.autotask.data.core.synclogs;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import javax.validation.Valid;

/**
 * mspbots.cw.core.core.synclogs.SysLogsController
 *
 * @author <a href="https://github.com/vnobo">Alex bob</a>
 * @date Created by 2020/10/19
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("logs/{tenantId}")
public class SyncLogsController {

    private final SyncLogsServiceImpl syncLogsService;

    @GetMapping("find")
    public Flux<SyncLogs> find(@PathVariable Long tenantId, @Valid SyncLogsRequest logsRequest, Pageable pageable) {
        return this.syncLogsService.find(tenantId, logsRequest, pageable);
    }

    @GetMapping("search")
    public Mono<Page<SyncLogs>> search(@PathVariable Long tenantId, @Valid SyncLogsRequest logsRequest, Pageable pageable) {
        return this.syncLogsService.search(tenantId, logsRequest, pageable);
    }

    @GetMapping("count")
    public Mono<JsonNode> count(@PathVariable Long tenantId, @Valid SyncLogsRequest logsRequest) {
        return this.syncLogsService.count(tenantId, logsRequest);
    }

    @GetMapping("stats")
    public Flux<StatsResponse> stats(@PathVariable Long tenantId) {
        return this.syncLogsService.stats(tenantId);
    }
}
